<div class="locations index">
<h2><?php __('Locations');?></h2>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
	<th><?php echo $paginator->sort(__('Id',true), 'id'); ?></th>
	<th><?php echo $paginator->sort(__('Country',true), 'country_id'); ?></th>
	<th><?php echo $paginator->sort(__('State',true), 'parent_id'); ?></th>
	<th><?php echo $paginator->sort(__('City',true), 'name'); ?></th>
	<th><?php echo $paginator->sort(__('Zip',true), 'zip'); ?></th>
	<th><?php echo $paginator->sort(__('Timezone',true), 'timezone'); ?></th>
    <th><?php echo __('Coordinate',true); ?></th>
	<th><?php echo $paginator->sort(__('Total Ads',true), 'ad_post_count'); ?></th>
	<th><?php echo $paginator->sort(__('Last Update',true), 'created'); ?></th>
	<th class="actions"><?php __('Actions'); ?></th>
</tr>
<?php
$i = 0;
$p = $paginator->current();
foreach ($locations as $location):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td>
			<?php e($location['Location']['id']); ?>
		</td>
		<td>
			<?php echo $html->link($location['Country']['name'], array('controller'=> 'countries', 'action'=>'view', $location['Country']['id'])); ?>
		</td>
		<td>
<?php
      if ($location['State']['name'] && $location['Location']['name']) {
          echo $html->link($location['State']['name'], array('controller'=> 'locations', 'action'=>'view', $location['State']['id']));
      } else {
          e($location['Location']['name']);
          $location['Location']['name'] = '';
      }
?>
		</td>
		<td>
			<?php e($location['Location']['name']); ?>
		</td>
		<td>
			<?php e($location['Location']['zip']); ?>
		</td>
		<td>
			<?php e($location['Location']['timezone']); ?>
		</td>
        <td>
<?php
      if ($location['Location']['latitude'] && $location['Location']['longitude']) {
          echo '('.$location['Location']['latitude'].', '.$location['Location']['longitude'].')';
      }
?>
        </td>
		<td>
			<?php e($location['Location']['ad_post_count']); ?>
		</td>
		<td>
			<?php e($location['Location']['created']); ?>
		</td>
		<td class="actions">
			<?php echo $html->link(__('View', true), array('action'=>'view', $location['Location']['id'])); ?>
			<?php echo $html->link(__('Edit', true), array('action'=>'edit', $location['Location']['id'], $p)); ?>
			<?php echo $html->link(__('Delete', true), array('action'=>'delete', $location['Location']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $location['Location']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 | 	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>
</div>
<div class="actions">
	<ul>
		<li><?php echo $html->link(__('New Location', true), array('action'=>'add')); ?></li>
		<li><?php echo $html->link(__('List Countries', true), array('controller'=> 'countries', 'action'=>'index')); ?> </li>
		<li><?php echo $html->link(__('New Country', true), array('controller'=> 'countries', 'action'=>'add')); ?> </li>
	</ul>
</div>
